'''
Created on Aug 20, 2009

@author: echeek
'''

def isPalindrome(st):
    for x in range(len(st)/2):
        if( st[x] != st[-(x+1)]):
            return False;
    return True;

def toBinary(n):
    out=[];
    while n>0:
        out.append( n & 1 );
        n=n>>1;
    return out;

def Euler36():
    sum=0;
    for x in range(1,1000000):
        if(isPalindrome(str(x)) and isPalindrome(toBinary(x))):
            sum+=x;
    print sum;
    
Euler36();